﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class CT_PhieuYeuCau_Data
    {
        KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
        public DataTable TaoBang(string sql)
        {
            return kn.taobang(sql);
        }
        public DataTable LayDuLieu()
        {
            return kn.LayDuLieu("");
        }
        public DataTable Load_GhiTra_GiaoVien(string soCaBiet)
        { 
            int Npara=1;
            string[] name = new string[Npara];
            object[] values = new object[Npara];
            name[0] = "@SoCaBiet";
            values[0] = soCaBiet;
            return kn.LayDuLieu("Load_GhiTra_GiaoVien",name,values,Npara);
        }
        public DataTable Load_GhiTra_HocVien(string soCaBiet)
        { 
            int Npara=1;
            string[] name = new string[Npara];
            object[] values = new object[Npara];
            name[0] = "@SoCaBiet";
            values[0] = soCaBiet;
            return kn.LayDuLieu("Load_GhiTra_HocVien", name, values, Npara);
        }
        public DataTable Load_TaiLieu_GhiTra(string maDocGia)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] values = new object[Npara];
            name[0] = "@MaDocGia";
            values[0] = maDocGia;
            return kn.LayDuLieu("Load_TaiLieu_GhiTra", name, values, Npara);
        }
        public DataTable Load_LichSuMuon(string maDocGia)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] values = new object[Npara];
            name[0] = "@MaDocGia";
            values[0] = maDocGia;
            return kn.LayDuLieu("Load_LichSuMuon", name, values, Npara);
        }
        public int Insert(CT_PhieuYeuCau_Public ct)
        {
            int nParameter =7;
            string[] name = new string[nParameter];
            object[] value = new object[nParameter];
            name[0] = "@MaPhieuYC";
            value[0] = ct.MaPhieuYC;
            name[1] = "@SoCaBiet";
            value[1] = ct.SoCaBiet;
            name[2] = "@NgayMuon";
            value[2] = ct.NgayMuon;
            name[3] = "@NgayDuTra";
            value[3] = ct.NgayDuTra;
            name[4] = "@TrangThaiGiaHan";
            value[4] = ct.TrangThaiGiaHan;
            name[5] = "@TrangThaiMuon";
            value[5]=ct.TrangThaiMuon;
            name[6] = "@MaNhanVien";
            value[6] = ct.MaNhanVien1;
            return kn.update("Insert_CT_PhieuYeuCau",name,value,nParameter);
        }
        public DataTable Load_ChiTiet_Muon(string maPhieu)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@MaPhieuYC";
            value[0] = maPhieu;
            return kn.LayDuLieu("Load_ChiTiet_Muon",name,value,Npara);
        }
        public int Update_GhiTra(CT_PhieuYeuCau_Public obj)
        {
            int Npara = 5;
            string[]name=new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@MaPhieuYC";
            value[0] = obj.MaPhieuYC;
            name[1] = "@SoCaBiet";
            value[1] = obj.SoCaBiet;
            name[2] = "@NgayTra";
            value[2] = obj.NgayTra;
            name[3] = "@TrangThaiMuon";
            value[3] = obj.TrangThaiMuon;
            name[4] = "@MaNhanVien";
            value[4] = obj.MaNhanVien1;
            return kn.update("Update_GhiTra",name,value,Npara);

        }
        public int Update_GiaHan(CT_PhieuYeuCau_Public obj)
        {
            int Npara = 5;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0]="@MaPhieuYC";
            value[0] = obj.MaPhieuYC;
            name[1] = "@SoCaBiet";
            value[1] = obj.SoCaBiet;
            name[2] = "@NgayDuTra";
            value[2] = obj.NgayDuTra;
            name[3] = "@TrangThaiGiaHan";
            value[3] = obj.TrangThaiGiaHan;
            name[4] = "@MaNhanVien";
            value[4] = obj.MaNhanVien1;

            return kn.update("Update_GiaHan",name,value,Npara);
        }
        public DataTable Load_GiaoVien_QuaHan(string maDocGia,string hoTen,string nhanDe,Boolean isNgayMuon,DateTime tuNgayMuon,DateTime denNgayMuon,Boolean isNgayTra,DateTime tuNgayTra,DateTime denNgayTra)
        {
            int Npara = 9;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@MaDocGia";
            value[0] = maDocGia;
            name[1] = "@HoVaTen";
            value[1] = hoTen;
            name[2] = "@NhanDe";
            value[2] = nhanDe;
            name[3] = "@isNgayMuon";
            value[3] = isNgayMuon;
            name[4] = "@TuNgayMuon";
            value[4] = tuNgayMuon;
            name[5] = "@DenNgayMuon";
            value[5] = denNgayMuon;
            name[6] = "@isNgayTra";
            value[6] = isNgayTra;
            name[7] = "@TuNgayTra";
            value[7] = tuNgayTra;
            name[8] = "@DenNgayTra";
            value[8] = denNgayTra;
            return kn.LayDuLieu("Load_GiaoVien_QuaHan",name,value,Npara);
        }
        public DataTable Load_HocVien_QuaHan(string maDocGia, string hoTen, string nhanDe, Boolean isNgayMuon, DateTime tuNgayMuon, DateTime denNgayMuon, Boolean isNgayTra, DateTime tuNgayTra, DateTime denNgayTra)
        {
            int Npara = 9;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@MaDocGia";
            value[0] = maDocGia;
            name[1] = "@HoVaTen";
            value[1] = hoTen;
            name[2] = "@NhanDe";
            value[2] = nhanDe;
            name[3] = "@isNgayMuon";
            value[3] = isNgayMuon;
            name[4] = "@TuNgayMuon";
            value[4] = tuNgayMuon;
            name[5] = "@DenNgayMuon";
            value[5] = denNgayMuon;
            name[6] = "@isNgayTra";
            value[6] = isNgayTra;
            name[7] = "@TuNgayTra";
            value[7] = tuNgayTra;
            name[8] = "@DenNgayTra";
            value[8] = denNgayTra;
            return kn.LayDuLieu("Load_HocVien_QuaHan",name,value,Npara);
        }
        public int Update_SoLuongMuon(int  soLuongMuon,string maDocGia)
        {
            int Npara = 2;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@SoLuongMuon";
            value[0] = soLuongMuon;
            name[1] = "@MaDocGia";
            value[1] = maDocGia;

            return kn.update("Update_SoLuongMuon", name, value, Npara);
        }
        public DataTable Load_ThongTinChiTiet_HocVien(string maDocGia)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@MaDocGia";
            value[0] = maDocGia;

            return kn.LayDuLieu("Load_ThongTinChiTiet_HocVien",name,value,Npara);
            
        }
        public DataTable Load_ThongTinChiTiet_GiaoVien(string maDocGia)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@MaDocGia";
            value[0] = maDocGia;

            return kn.LayDuLieu("Load_ThongTinChiTiet_GiaoVien", name, value, Npara);
        }
        public DataTable Load_GiaHan(string soCaBiet)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@SoCaBiet";
            value[0] = soCaBiet;

            return kn.LayDuLieu("Load_GiaHan", name, value, Npara);
        }
    }
}
